﻿using FRRJIf;
using RJi.FanucInterface3.Common.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RJi.FanucInterface3.Common.Internal
{
    internal class RbtIOWrapper : IRbtIOWrapper
    {
        private readonly Core _core;
        private readonly Dictionary<string, VariableMetadata> _inputMetadataCache;
        private readonly Dictionary<string, VariableMetadata> _outputMetadataCache;

        public RbtIOWrapper(Core core, Dictionary<string, VariableMetadata> inputMetadataCache, Dictionary<string, VariableMetadata> outputMetadataCache)
        {
            _core=core;
            _inputMetadataCache=inputMetadataCache;
            _outputMetadataCache=outputMetadataCache;
        }

        public IRbtIOWrapper RegisterInput(InputType type, int startIndex = 1, int count = 1, string? key = null)
        {
            key??=$"{type.ToString()}{startIndex}:{count}";
            _inputMetadataCache[key]=new VariableMetadata(type, typeof(InputType), true, startIndex, count);
            return this;
        }

        public IRbtIOWrapper RegisterOutput(OutputType type, int startIndex = 1, int count = 1, string? key = null)
        {
            key??=$"{type.ToString()}{startIndex}:{count}";
            _outputMetadataCache[key]=new VariableMetadata(type, typeof(OutputType), true, startIndex, count);
            return this;
        }
    }
}